#ifndef SEU_CLIENT_H
#define SEU_CLIENT_H
#include"include.h"
//This is made in anticipation of running on multiple ports
//This would most easily be done by having distincly defined
//client sections so multiple instances could be made.
//This also is a convenient way to pass a lot of information
//around and conceptually it creates a neat high-level struct
//to hold all the information. 


typedef struct {
   char *peer_id;
   uint16_t port;       // Listen for handshakes

   list_t *torrents;

   short running;

   pthread_t listenThread;

} client_t;

client_t *clientInit(uint16_t port);
int clientAddTorrentFile(client_t *c, char *f);
int clientStartTorrent(client_t *c, torrent_t *t);
int clientStopTorrent(client_t *c, torrent_t *t);
int clientPauseTorrent(client_t *c, torrent_t *t);
int clientResumeTorrent(client_t *c, torrent_t *t);
int clientRemoveTorrent(client_t *c, torrent_t *t);
int clientForceAnnounce(client_t *c, torrent_t *t);

/* clientAwaitHandshake listens on the client_t's port for peers wishing to
 * handshake.
 *
 * This function blocks until a peer becomes available, or until the timeout
 * time is reached. If a negative timeout is specified, the function blocks
 * indefinitely until a peer arrives.
 */
void *clientAwaitHandshake(client_t *c);

struct peer_struct;
void clientAddPeer(client_t *c, struct peer_struct *p,
      unsigned char *info_hash);

void *clientEventLoop(client_t *c);

void clientExit(client_t *c);

list_t *clientGetTorrents(client_t *c);

#endif
